{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Bubble Sort"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "numbers = [20, 10, 16, 6, 89]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(0, len(numbers)-1):\n",
    "    for j in (i+1, len(numbers)-1):\n",
    "        if numbers[i] < numbers[j]:\n",
    "            temp = numbers[j]\n",
    "            numbers[j] = numbers[i]\n",
    "            numbers[i] = temp\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[89, 20, 16, 10, 6]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Insertion Sort"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "numbers = [20, 10, 16, 6, 89]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(len(numbers) -1):\n",
    "    if i > 0:\n",
    "        for j in range(i+1):\n",
    "            if numbers[i] < numbers[j]:\n",
    "                temp = numbers[i]\n",
    "                numbers[i] = numbers[j]\n",
    "                numbers[j] = temp\n",
    "                 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[6, 10, 16, 20, 89]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Replace String only use another String"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](https://lh3.googleusercontent.com/BQ0X68Y2yGZ1uu9gOlAd8V40Tdi5SsZrme9FWF_gsHaJ7H2Tg4JZs06PqrjeSttTZBi6wxdOGcJ9BlAcf-wcrAzL2rVIfmC5kKlGvUVs0iBgXYPAaloljWtAmFlbg0V5H7s5dbg_-ZsdKFejHCxZdnRmITY8b27d4r6pN1fosBogozAVVLlQbtqaZ9-03qbnmVROvfFg6I_2nzZ84V849NF0o_rv3-sJQ6YT7WWb6u1jgTCbv9IxM5RmNUdgvl7blcuBl4QCe0v6dpFhWiP62ikneiU6l3FLzjIGHjsbKXxKSNFEAoEV5fglOfPS6wy6InQGL_45ykDIAKGsO2KQznHw17D2y6gdSHxUBDJ0EdEEuwQNsh3TVr0p3K3GPileWvAByDX-UcE1ZpvMy_BYFLJVMRbu0QBZ8PfuvUKeT3Y0fxI4EdbOZthEwemY2EgUeU_5jafmr_tb58i7kY4xeSa5YCqjF_IozIM59vfXkCIrdUecW2vqJ2YMigv5U_DhC1j797XAxLXKRM93vw81qVDjJIgyuQOImLhPM9KkHLImCfpU77xR54BDXYuT_JsHkjJdTq5hc8ZxbXpJMLIIfWv2WNrrs8e5Ywz7bkvWX5oyVcKx1HmJwdVff9lPE2LYpqRdbKdsTF96t4IrjylzyE2M-ZQIpcr1ur-TkI0ya6omK03vQ7R-UdrM9g=w519-h387-no)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is the original message used\n",
      "Thos os thi urogonel missegi asid\n",
      "disa igessim lenogoru iht so sohT\n"
     ]
    }
   ],
   "source": [
    "names = \"This is the original message used\"\n",
    "names2 = \"\"\n",
    "for i in range(len(names)):\n",
    "    if names[i] == \"a\":\n",
    "        names2 = names2 + \"e\"\n",
    "    elif names[i] == \"e\":\n",
    "        names2 = names2 + \"i\"\n",
    "    elif names[i] == \"i\":\n",
    "        names2 = names2 + \"o\"\n",
    "    elif names[i] == \"o\":\n",
    "        names2 = names2 + \"u\"\n",
    "    elif names[i] == \"u\":\n",
    "        names2 = names2 + \"a\"\n",
    "    else:\n",
    "        names2 = names2 + names[i]\n",
    "print(names)\n",
    "print(names2)\n",
    "print(names2[::-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](https://lh3.googleusercontent.com/YBhjEZfhYHDFDuSU9FNDEfswjFyJse5AMYfXcjXL4-1N0-AwimsTn8Rj8BwrG57xW1YAfgU9wyDPeSR3_4ed8EXkLu0rSkwF7iFL3RSSDmzIUE6ph3C7YSzqwu4-0dbo6HM_y0rKSW2gv-JpWhwCHOVAAtEm4AKu0gVR_RGrkkWaQ-P0wosrMjUh5vnCUlRpzP6TGwkZ1vLzFz1fKa2FUrZuSCsYyKBzqzx5AtMu7_BRnk9JO3a-X-Z0WGYErGyggBOAdR3ExzcIcPs7hchKUehQuLTm0uO5AiDttzBwBLKFNXA1w75cNcyJmRpXZ_XRVatLZ8Rski8GZFCViGrHe-sBcRw1N5DGNQt_BKHJZZvibVGX0vt-ISfEuJyLcMx7uSx6_E4hoEcBSQ2E64c1qr1mweWJjv8nQf5icnyH0Rv5pQPI3ZDgbW2KKo2o-mZmhuF2EPimVpYnJDS1vF6UdR3-U_FJ0HtRkanACU5cu4hTE_JXFGzrIZL3PlI6lEhyX8gUTxHMITYzCwf3dNRvHNxkaTAw9elnELUAEXjEDndSK9v-Z9zIaXuVGJnvVuH7b8AKVBk1SXLuOx-glP_jJEDgiim7-n_dkTtOxQMraoKuLY0X3eBBWO50YqvzMEef0Tf5a3chH7g1ifMoPoyeRSOHTMCv2-4lRXhT5F6-1yChqeCLvGYGHdGCUg=w891-h518-no)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# ignore special cases\n",
    "\n",
    "def get_num_str(n):\n",
    "    chars = []\n",
    "    if n >2:\n",
    "        for num in range(1, n-1):\n",
    "            chars.append(str(num))\n",
    "            chars.append(str(num+2))\n",
    "    return \"-\".join(chars)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1-3'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_num_str(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1-3-2-4-3-5-4-6'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_num_str(6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
